goog.provide('dkpoints.labs');

goog.require('dkpoints.rpc');
goog.require('dkpoints.rpc.commands.GetInstanceTier');
goog.require('dkpoints.status');

dkpoints.labs.name = "Labs";

dkpoints.labs.sayHi = function() {
  var me = dkpoints.labs;
  var status = dkpoints.status;
  
  me.start = Date.now();
  status.addMessage("Starting request.", "start", "Labs: RPC Cache", 10000);
  
  var newGetInstanceTier = new dkpoints.rpc.commands.GetInstanceTier(me.gotHi, "Icecrown Citadel");
  dkpoints.rpc.execute(newGetInstanceTier);
};

/**
 * Test callback for rpc command.
 * @param {!Object} cmdResponse The response data given back from the executed command.
 */
dkpoints.labs.gotHi = function(cmdResponse) {
  var me = dkpoints.labs;
  
  // cmdResponse.error will be defined if something bad happened.
  if(! goog.isDef(cmdResponse.error)) {
    // Nothing bad happened.
    console.log("Command response:");
    console.log(cmdResponse.instanceTier);
  }
  else {
    // Something bad happened.
    console.log("We're fucked.");
  }
  
  dkpoints.status.addMessage("End request: " + (Date.now() - me.start) + "ms.", "done", "Labs: RPC Cache", 10000);
};